package com.dkd.testChoose.controller;


import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.core.domain.R;
import com.dkd.common.core.page.TableDataInfo;
import com.dkd.testChoose.domain.TestChoose;
import com.dkd.testChoose.service.ITestChooseService;
import com.dkd.testRank.domain.TestRank;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 选择你的英雄位置 前端控制器
 * </p>
 *
 * @author zwy
 * @since 2025-05-21
 */
@Api(tags = "选择你的英雄")
@RestController
@RequestMapping("/testChoose")
public class TestChooseController extends BaseController {
    @Autowired
    private ITestChooseService chooseService;
    /**
     * 查询选择列表
     */
    @ApiOperation("查询列表")
    @PreAuthorize("@ss.hasPermi('testChoose:choose:list')")
    @GetMapping("/list")
    public TableDataInfo list(TestChoose testChoose) {
        startPage();
        return getDataTable(chooseService.selectList(testChoose));
    }

    /**
     * 详情
     *
     * @param id
     * @return 写入了redis
     */
    @ApiOperation("查询详情")
    @PreAuthorize("@ss.hasPermi('testChoose:choose:query')")
    @GetMapping(value = "/{id}")
    public R<TestChoose> getInfo(@PathVariable("id") Integer id) {
        return R.ok(chooseService.selectById(id));
    }

    /**
     * 新增
     */
    @ApiOperation("新增")
    @PreAuthorize("@ss.hasPermi('testChoose:choose:add')")
    @PostMapping
    public AjaxResult insertTestChoose(@RequestBody TestChoose testChoose) {
        return AjaxResult.success(chooseService.insertTestChoose(testChoose));
    }

    /**
     * 批量删除
     * @param
     * @return 删除操作的结果
     */
    @ApiOperation("批量删除")
    @PreAuthorize("@ss.hasPermi('testChoose:choose:remove')")
    @DeleteMapping
    public AjaxResult deleteTestChooses(TestChoose testChoose) {
        return AjaxResult.success(chooseService.deleteTestChoose(testChoose));
    }


    /**
     * @param testChoose
     * @return 返回AjaxResult对象，用于封装操作结果
     */
    @ApiOperation("修改")
    @PreAuthorize("@ss.hasPermi('testChoose:choose:edit')")
    @PutMapping
    public AjaxResult updateTestChoose(@RequestBody TestChoose testChoose) {
        return AjaxResult.success(chooseService.updateTestChoose(testChoose));
    }

}
